import React from "react";
import './TodoFooter.css';

export default function TodoFooter(props) {
  //获取父级组件传入的数据
  let {checkAllTodo, todos, removeDoneTodos} = props;
  return (
    <div className="todo-footer">
      <label>
        <input type="checkbox" 
          checked={todos.every(item => item.done) && todos.length > 0}
          onChange={(e) => {
            checkAllTodo(e.target.checked);
          }}/>
      </label>
      <span>
        <span>已完成 {todos.filter(item => item.done).length}</span> / 全部 {todos.length}
      </span>
      <button className="btn btn-danger" onClick={removeDoneTodos}>清除已完成任务</button>
    </div>
  );
}
